import request from '@/utils/request';

export function getStruct(listId: any) {
	return request({
		url: `/api/dm/struct/${listId}`,
		method: 'get',
	});
}

export function get(query: any, listId: any) {
	if (typeof query === 'object' && query !== null) {
		return request({
			url: `/api/x?t=${listId}`,
			method: 'get',
			params: query,
		});
	} else {
		return request({
			url: `/api/x/${query}?t=${listId}`,
			method: 'get',
		});
	}
}

export function add(data: any, listId: any) {
	return request({
		url: `/api/x?t=${listId}`,
		method: 'post',
		data: data,
	});
}

export function update(query: any, data: any, listId: any) {
	return request({
		url: `/api/x/${query}?t=${listId}`,
		method: 'put',
		data: data,
	});
}

export function del(data: any, listId: any) {
	return request({
		url: `/api/x?t=${listId}`,
		method: 'delete',
		params: data,

		// 存在批量删除，pk为数组
		// {
		//     partner_id: pk
		// }
	});
}


export function getDict(query: any,) {
	return request({
		url: `/api/f?f=hTkdp9xadts&dictType=${query}`,
		method: 'get',
	});
}